package com.aceslideshows.common.dao;

import java.io.Serializable;
import java.util.List;

/**
 * Data Access Object (DAO) interface. This is an interface used to tag our DAO
 * classes and to provide common methods to all DAOs.
 * 
 * <p>
 * <a href="GenericDao.java.html"><i>View Source</i></a>
 * </p>
 */
public interface GenericDao<T, PK extends Serializable>
{

    /** Remove an object from persistent storage in the database */
    void delete(T persistentObject);

    /**
     * Retrieve an object that was previously persisted to the database using
     * the indicated id as primary key
     */
    T find(PK id);

    /**
     * Generic method used to get all objects of a particular type. This is the
     * same as lookup up all rows in a table.
     * 
     * @return List of populated objects
     * 
     */
    List<T> findAll();

    /**
     * Re-attaches an object to the current context.
     * 
     * @param o
     * @return
     */
    void saveOrUpdate(T o);

    /**
     * Re-reads and re-attaches an object to the current context.
     * 
     * @param o
     * @return
     */
    void refresh(T o);

}